/**
 * JAVACC DEMO 1.0
 * @copy right apache company All rights reserved. 
 * @Package com.apache.rpc.entity  
 */
package com.apache.rpc.server.threads;

import com.apache.cache.util.Validator;

/**
 * description:  socket线程参数配置
 * @author Hou Dayu 创建时间：2015-1-7  
 * @Copyright(c)2014:
 */

public class SocketConfig implements Runnable {

	//时间间隔(毫秒)
	private int sleepInterval = 1000;
	//任务
	private ISchedulerJob job;

	public SocketConfig() {

	}

	public SocketConfig(int sleepInterval, ISchedulerJob job) {
		this.sleepInterval = sleepInterval;
		this.job = job;
	}

	public int getSleepInterval() {
		return sleepInterval;
	}

	public void setSleepInterval(int sleepInterval) {
		this.sleepInterval = sleepInterval;
	}

	public ISchedulerJob getJob() {
		return job;
	}

	public void setJob(ISchedulerJob job) {
		this.job = job;
	}

	@Override
	public void run() {
		boolean flag = true;
		while (flag) {
			try {
				if (!Validator.isEmpty(job)) {
					flag = job.execute();
				}
				Thread.sleep(sleepInterval);
			} catch (Exception e) {
			}
		}
	}

}
